package com.data241210.SpringbootDemo.service.impl;

import com.data241210.SpringbootDemo.mapper.StudentMapper;
import com.data241210.SpringbootDemo.model.Student;
import com.data241210.SpringbootDemo.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;

    //获取全部数据
    @Override
    @Cacheable(value = "studentListCache")
    public List<Student> findAll(){
        System.out.println("执行数据库查询操作，返回所有学生信息");
        return studentMapper.findAll();
    }

    //保存数据
    @Override
    public int save(Student student){
        return studentMapper.save(student);
    }

    //删除数据
    @Override
    public int delete(Integer sno){
        return studentMapper.delete(sno);
    }

    //按学号查找数据
    @Override
    public Student findBySno(Integer sno){
        return studentMapper.findBySno(sno);
    }

    //更新数据
    @Override
    public int update(Student student){
        return studentMapper.update(student);
    }

    //按姓名查找数据
    @Override
    public List<Student> findByName(String sname){
        return null;
    }
}
